<?php
include("include/config.inc.php");
if(!isset($_SESSION['s_activId']))
{
  $_SESSION['s_urlRedirectDir'] = $_SERVER['REQUEST_URI'];
  header("Location:checkLogin.php");
}
else
{
 
	$incomingRegister = array();
	$incomingDetailArray = array();
  $a =0;
  $msg                = "No Record Found";
  
  $selectincomingRegister = "SELECT incomingId,partyName,DATE_FORMAT(incoming.IncomingDate,'%d-%m-%Y')AS IncomingDate,qty,challan,weight,
                                    processName1.processName AS processName1,processName2.processName AS processName2,
                                    processName3.processName AS processName3,materialName,hardne,column1,column2,column3,column4,column5,column6
	                             FROM incoming
	                             LEFT JOIN party ON party.partyId = incoming.partyId
	                             LEFT JOIN process AS processName1 ON processName1.processId = incoming.processId1
	                             LEFT JOIN process AS processName2 ON processName2.processId = incoming.processId2
	                             LEFT JOIN process AS processName3 ON processName3.processId = incoming.processId3
	                             LEFT JOIN material ON material.materialId = incoming.materialId
	                            WHERE incomingId = ".$_GET['incomingId'];
	$selectincomingRegisterRes = mysql_query($selectincomingRegister);
	if($incomingRow = mysql_fetch_array($selectincomingRegisterRes))
	{
		$incomingRegister['incomingId']   = $incomingRow['incomingId'];
		$incomingRegister['partyName']    = $incomingRow['partyName'];
		$incomingRegister['IncomingDate'] = $incomingRow['IncomingDate'];
		$incomingRegister['qty']          = $incomingRow['qty'];
		$incomingRegister['challan']      = $incomingRow['challan'];
		$incomingRegister['weight']       = $incomingRow['weight'];
		$incomingRegister['processName1'] = $incomingRow['processName1'];
		$incomingRegister['processName2'] = $incomingRow['processName2'];
		$incomingRegister['processName3'] = $incomingRow['processName3'];
		$incomingRegister['material']     = $incomingRow['materialName'];
		$incomingRegister['hardne']       = $incomingRow['hardne'];
		$incomingRegister['column1']       = $incomingRow['column1'];
		$incomingRegister['column2']       = $incomingRow['column2'];
		$incomingRegister['column3']       = $incomingRow['column3'];
		$incomingRegister['column4']       = $incomingRow['column4'];
		$incomingRegister['column5']       = $incomingRow['column5'];
		$incomingRegister['column6']       = $incomingRow['column6'];
		
	 $selectincomingRegister  = "SELECT IncomingDetailId,incomingId,columns1,columns2,columns3,columns4,columns5,columns6 
		                           FROM incomingdetail
		                           WHERE incomingId = ".$incomingRow['incomingId'];
		
		
		$selectincomingRegisterRes = mysql_query($selectincomingRegister);
		while($selectRow = mysql_fetch_array($selectincomingRegisterRes))
		{
		  $incomingDetailArray[$a]['IncomingDetailId'] = $selectRow['IncomingDetailId'];
		  $incomingDetailArray[$a]['incomingId']       = $selectRow['incomingId'];
		  $incomingDetailArray[$a]['columns1']           = $selectRow['columns1'];
		  $incomingDetailArray[$a]['columns2']            = $selectRow['columns2'];
		  $incomingDetailArray[$a]['columns3']            = $selectRow['columns3'];
		  $incomingDetailArray[$a]['columns4']             = $selectRow['columns4'];
		  $incomingDetailArray[$a]['columns5']          = $selectRow['columns5'];
		  $incomingDetailArray[$a]['columns6']          = $selectRow['columns6'];
		  $a++;
		}		
	}
      

  include("./bottom.php");
  $smarty->assign("incomingDetailArray",$incomingDetailArray);
  $smarty->assign("msg",$msg);
  $smarty->assign("incomingRegister",$incomingRegister);
	$smarty->display('incomingRegistreDetail.tpl');
}
?>